﻿using System.Collections;

using System.Collections.Generic;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Sensors;
using Unity.MLAgents.Actuators;

public class PlaceHolderAgent : Agent
{
    public EnvironmentController envCtrler;
    private void Awake()
    {
        envCtrler = GameObject.Find("EnvironmentController").GetComponent<EnvironmentController>();
    }

    public override void Initialize()
    {
        Academy.Instance.AgentPreStep += DoDecisionRequestRoutine;
        RequestDecision();
    }
    
    public void DoDecisionRequestRoutine(int academyStepCount)
    {
        //prevent the env.step() in python from stacking.
        if (envCtrler.GetDone())
            RequestDecision();
    }

    public override void CollectObservations(VectorSensor sensor)
    {
        // Target and Agent positions
        sensor.AddObservation(0);
    }

    public override void Heuristic(in ActionBuffers actionsOut)
    {
        var actions = actionsOut.ContinuousActions;
        actions[0] = 0;
    }
}
